﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace DARE.Save.DataStructures
{
    public class CEffectMgrData : ISaveData
    {
        public bool PerPixelLighteningEnabled;
        public bool LighteningEnabled;
        public Color AmbientLightColor;
        public float AmbientLightIntensity;
        public Vector3 DirectionalLight1Direction;
        public Color DirectionalLight1DiffuseColor;
        public float DirectionalLight1DiffuseIntensity;
        public Color DirectionalLight1SpecularColor;
        public float DirectionalLight1SpecularIntensity;
        public Vector3 DirectionalLight2Direction;
        public Color DirectionalLight2DiffuseColor;
        public float DirectionalLight2DiffuseIntensity;
        public Color DirectionalLight2SpecularColor;
        public float DirectionalLight2SpecularIntensity;
        public Vector3 DirectionalLight0Direction;
        public Color DirectionalLight0DiffuseColor;
        public float DirectionalLight0DiffuseIntensity;
        public Color DirectionalLight0SpecularColor;
        public float DirectionalLight0SpecularIntensity;


        public void FillDataStructure(object effectMgr)
        {
            CEffectMgr mgr = effectMgr as CEffectMgr;
            PerPixelLighteningEnabled = mgr.PerPixelLighteningEnabled;
            LighteningEnabled = mgr.LighteningEnabled;
            AmbientLightColor = mgr.AmbientLightColor;
            AmbientLightIntensity = mgr.AmbientLightIntensity;
            DirectionalLight1Direction = mgr.DirectionalLight1Direction;
            DirectionalLight1DiffuseColor = mgr.DirectionalLight1DiffuseColor;
            DirectionalLight1DiffuseIntensity = mgr.DirectionalLight1DiffuseIntensity;
            DirectionalLight1SpecularColor = mgr.DirectionalLight1SpecularColor;
            DirectionalLight1SpecularIntensity = mgr.DirectionalLight1SpecularIntensity;
            DirectionalLight2Direction = mgr.DirectionalLight2Direction;
            DirectionalLight2DiffuseColor = mgr.DirectionalLight2DiffuseColor;
            DirectionalLight2DiffuseIntensity = mgr.DirectionalLight2DiffuseIntensity;
            DirectionalLight2SpecularColor = mgr.DirectionalLight2SpecularColor;
            DirectionalLight2SpecularIntensity = mgr.DirectionalLight2SpecularIntensity;
            DirectionalLight0Direction = mgr.DirectionalLight0Direction;
            DirectionalLight0DiffuseColor = mgr.DirectionalLight0DiffuseColor;
            DirectionalLight0DiffuseIntensity = mgr.DirectionalLight0DiffuseIntensity;
            DirectionalLight0SpecularColor = mgr.DirectionalLight0SpecularColor;
            DirectionalLight0SpecularIntensity = mgr.DirectionalLight0SpecularIntensity;
        }

        public void FillFromDataStructure(out object effectMgr, params object[] paramsData)
        {
            effectMgr = null;
            if (paramsData.Length <= 0 || !(paramsData[0] is CRender3D))
                return;
            CEffectMgr mgr = new CEffectMgr(paramsData[0] as CRender3D);
            mgr.PerPixelLighteningEnabled = PerPixelLighteningEnabled;
            mgr.LighteningEnabled = LighteningEnabled;
            mgr.AmbientLightColor = AmbientLightColor;
            mgr.AmbientLightIntensity = AmbientLightIntensity;
            mgr.DirectionalLight1Direction = DirectionalLight1Direction;
            mgr.DirectionalLight1DiffuseColor = DirectionalLight1DiffuseColor;
            mgr.DirectionalLight1DiffuseIntensity = DirectionalLight1DiffuseIntensity;
            mgr.DirectionalLight1SpecularColor = DirectionalLight1SpecularColor;
            mgr.DirectionalLight1SpecularIntensity = DirectionalLight1SpecularIntensity;
            mgr.DirectionalLight2Direction = DirectionalLight2Direction;
            mgr.DirectionalLight2DiffuseColor = DirectionalLight2DiffuseColor;
            mgr.DirectionalLight2DiffuseIntensity = DirectionalLight2DiffuseIntensity;
            mgr.DirectionalLight2SpecularColor = DirectionalLight2SpecularColor;
            mgr.DirectionalLight2SpecularIntensity = DirectionalLight2SpecularIntensity;
            mgr.DirectionalLight0Direction = DirectionalLight0Direction;
            mgr.DirectionalLight0DiffuseColor = DirectionalLight0DiffuseColor;
            mgr.DirectionalLight0DiffuseIntensity = DirectionalLight0DiffuseIntensity;
            mgr.DirectionalLight0SpecularColor = DirectionalLight0SpecularColor;
            mgr.DirectionalLight0SpecularIntensity = DirectionalLight0SpecularIntensity;

            effectMgr = mgr;
        }
    }
}
